//
// Globals.h -- Defines typedefs and global variables.
//              This is a cutdown version, suitable for linkage from userland
//              programs.
//

#ifndef GLOBALS_H
#define GLOBALS_H

#define NULL 0

#undef size_t
typedef unsigned int    uint;
typedef long unsigned int  size_t;
typedef unsigned long long u64int;
typedef          long long s64int;
typedef unsigned int    u32int;
typedef          int    s32int;
typedef unsigned short  u16int;
typedef          short  s16int;
typedef unsigned char   u8int;
typedef          char   s8int;

typedef unsigned int    Address;

#define PANIC(x) 
#define ERROR(x)
#define ASSERT(x)

// Usually defined in memory/MemoryManagement.h
#define HEAP_START         0xC0000000
#define HEAP_INITIAL_SIZE  0x100000
#define USER_HEAP_START    0xD0000000
#define USER_HEAP_INITIAL_SIZE 0x100000
#define STACK_START        (0xB0000000-0x4)
#define STACK_INITIAL_SIZE 0x4000
#define STACK_END          0xA0000000
#define KERNEL_START       0x100000

#define STACK_ADDRESS(x) ((u32int)x <= STACK_START && (u32int)x > STACK_END)
#define HEAP_ADDRESS(x)  ((u32int)x >= HEAP_START  && (u32int)x < USER_HEAP_START)
#define USER_HEAP_ADDRESS(x) ((u32int)x >= USER_HEAP_START && (u32int)x < 0xF0000000)

#define SYSCALL_FORK            1
#define SYSCALL_EXECVE          17
#define SYSCALL_EXIT            2
#define SYSCALL_YIELD           3
#define SYSCALL_YIELDTO         4
#define SYSCALL_NULL            5
#define SYSCALL_REQUEST         6
#define SYSCALL_MORERPC         7
#define SYSCALL_CREATERESOURCE  8
#define SYSCALL_ADDFUNC0        9
#define SYSCALL_ADDFUNC1        10
#define SYSCALL_ADDFUNC2        11
#define SYSCALL_ADDFUNC3        12
#define SYSCALL_ADDFUNC4        13
#define SYSCALL_ADDFUNC5        14
#define SYSCALL_DESTROYRESOURCE 15
#define SYSCALL_UFREE           16

extern void *operator new(size_t, bool);
extern void *operator new[](size_t, bool);
extern void operator delete(void *, bool);
extern void operator delete[](void *, bool);

extern Address _currentKernelStack;

#endif // GLOBALS_H
